Skip to content

Azure mysql postgres auto discovery config create#15630

Merged
GavinFrazar merged 11 commits into
masterfrom
gavinfrazar/azure_mysql_postgres_auto_discovery_config_create
Aug 19, 2022
Merged

Azure mysql postgres auto discovery config create#15630
GavinFrazar merged 11 commits into
masterfrom
gavinfrazar/azure_mysql_postgres_auto_discovery_config_create

Conversation

@GavinFrazar
Copy link
Copy Markdown
Contributor

@GavinFrazar GavinFrazar commented Aug 17, 2022

This PR adds config creation commands only for azure regions.

Example: teleport db configure create --azure-mysql-discovery=eastus,westus --azure-mysql-discovery=centralus

Example Output:

# Teleport database agent configuration file.
# Configuration reference: https://goteleport.com/docs/database-access/reference/configuration/
#
teleport:
  nodename: mac.attlocal.net
  data_dir: /var/lib/teleport
  auth_token: /tmp/token
  auth_servers:
  - 0.0.0.0:3080
db_service:
  enabled: "yes"
  # Matchers for database resources created with "tctl create" command.
  # For more information: https://goteleport.com/docs/database-access/guides/dynamic-registration/
  resources:
  - labels:
      "*": "*"
  # Matchers for registering Azure-hosted databases.
  azure:
  # Azure MySQL databases auto-discovery.
  # For more information about Azure MySQL auto-discovery: https://goteleport.com/docs/database-access/guides/azure-postgres-mysql/
  - subscriptions: ["*"]
    resource_groups: ["*"]
    types: ["mysql"]
    # Azure regions to register databases from.
    regions:
    - eastus,westus
    - centralus
    # Azure resource tags to match when registering databases.
    tags:
      "*": "*"
# (rest of irrelevant config omitted by me)

This is a part of a larger issue to implement Azure MySQL/PostgreSQL auto-discovery: #14688

This PR branched off #15629 so github will automatically retarget the base branch to master when that PR merges.

@GavinFrazar GavinFrazar added feature-request Used for new features in Teleport, improvements to current should be #enhancements database-access Database access related issues and PRs db/postgres PostgreSQL related database access issues db/mysql MySQL related database access issues azure labels Aug 17, 2022
@GavinFrazar GavinFrazar self-assigned this Aug 17, 2022
@GavinFrazar GavinFrazar marked this pull request as ready for review August 17, 2022 22:21
Comment thread tool/teleport/common/teleport.go Outdated
Base automatically changed from gavinfrazar/azure_mysql_postgres_auto_discovery_configuration to master August 19, 2022 19:48
@GavinFrazar GavinFrazar enabled auto-merge (squash) August 19, 2022 19:56
@GavinFrazar GavinFrazar merged commit d6e3202 into master Aug 19, 2022
@GavinFrazar GavinFrazar deleted the gavinfrazar/azure_mysql_postgres_auto_discovery_config_create branch August 26, 2022 00:14
GavinFrazar added a commit that referenced this pull request Aug 31, 2022
* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Add config create flags for azure matchers

* Add config create tests for azure

* Move discovery flags for azure below aws

* Fixup merge
GavinFrazar added a commit that referenced this pull request Aug 31, 2022
* Azure mysql postgres auto discovery configuration (#15629)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Update lib/services/matchers.go

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/services/matchers.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Remove superfluous cmp option for diffing azure matcher

* Rename AzureMatchers Tags to ResourceTags

* Deduplicate subscription/resource groups and add tests

* Remove azure matcher config fixup

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Azure mysql postgres auto discovery config create (#15630)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Add config create flags for azure matchers

* Add config create tests for azure

* Move discovery flags for azure below aws

* Fixup merge

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>
GavinFrazar added a commit that referenced this pull request Aug 31, 2022
* Azure mysql postgres auto discovery configuration (#15629)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Update lib/services/matchers.go

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/services/matchers.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Remove superfluous cmp option for diffing azure matcher

* Rename AzureMatchers Tags to ResourceTags

* Deduplicate subscription/resource groups and add tests

* Remove azure matcher config fixup

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Azure mysql postgres auto discovery config create (#15630)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Add config create flags for azure matchers

* Add config create tests for azure

* Move discovery flags for azure below aws

* Fixup merge

* Add Azure resource ID to protos (#15673)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Update protobuf and fix database serialization

* Update azure database spec/status

* Change proto to use resource id string

* Fix database serialization test

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>
GavinFrazar added a commit that referenced this pull request Aug 31, 2022
* Azure mysql postgres auto discovery configuration (#15629)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Update lib/services/matchers.go

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/services/matchers.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Remove superfluous cmp option for diffing azure matcher

* Rename AzureMatchers Tags to ResourceTags

* Deduplicate subscription/resource groups and add tests

* Remove azure matcher config fixup

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Azure mysql postgres auto discovery config create (#15630)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Add config create flags for azure matchers

* Add config create tests for azure

* Move discovery flags for azure below aws

* Fixup merge

* Azure API for DB discovery (#15674)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Go mod tidy to update dependencies

* Add azure response error conversion

* Check for azure access denied and give a helpful error message

* Add azure subscriptions api

* Add azure mysql/postgresql api and wrappers

* Test generic db server for azure

* Make server properties its own type

* Convert server types manually instead of via json

* Move server list method selection logic out of api client

* Update azure db server tests

* Fixup merge

* Update comments

* Update more comments and remove junk code

* Move all azure api into lib/cloud/azure

* Update state and version checks

* Add mutex to subscription client for caching, just in case

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/subscriptions_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Rename azure subscription client and remove sub ID caching

* Add reference links for azure db ports

* Move indirect dep into group

* Wrap all converted azure response errors

* Remove unreachable panic

* Godoc DBServer

* Remove maxPages arg to azure client funcs

* Gofmt

* Spacing between copyright and package

* import order

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Bump go.mod version to 1.18

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>
GavinFrazar added a commit that referenced this pull request Sep 1, 2022
* Azure mysql postgres auto discovery configuration (#15629)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Update lib/services/matchers.go

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/config/fileconf.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/services/matchers.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Remove superfluous cmp option for diffing azure matcher

* Rename AzureMatchers Tags to ResourceTags

* Deduplicate subscription/resource groups and add tests

* Remove azure matcher config fixup

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Azure mysql postgres auto discovery config create (#15630)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Add config create flags for azure matchers

* Add config create tests for azure

* Move discovery flags for azure below aws

* Fixup merge

* Azure API for DB discovery (#15674)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Go mod tidy to update dependencies

* Add azure response error conversion

* Check for azure access denied and give a helpful error message

* Add azure subscriptions api

* Add azure mysql/postgresql api and wrappers

* Test generic db server for azure

* Make server properties its own type

* Convert server types manually instead of via json

* Move server list method selection logic out of api client

* Update azure db server tests

* Fixup merge

* Update comments

* Update more comments and remove junk code

* Move all azure api into lib/cloud/azure

* Update state and version checks

* Add mutex to subscription client for caching, just in case

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/subscriptions_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Rename azure subscription client and remove sub ID caching

* Add reference links for azure db ports

* Move indirect dep into group

* Wrap all converted azure response errors

* Remove unreachable panic

* Godoc DBServer

* Remove maxPages arg to azure client funcs

* Gofmt

* Spacing between copyright and package

* import order

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Bump go.mod version to 1.18

* Azure MySQL and PostgreSQL DB Discovery (#15745)

* Add Azure auto-discovery configuration fields

* Init databases if azure matchers are in config

* Use AzureMatchers in db service

* Use all azure subscriptions/resource groups if omitted in matcher

* Add azure config tests

* Go mod tidy to update dependencies

* Add azure response error conversion

* Check for azure access denied and give a helpful error message

* Add azure subscriptions api

* Add azure mysql/postgresql api and wrappers

* Test generic db server for azure

* Make server properties its own type

* Convert server types manually instead of via json

* Move server list method selection logic out of api client

* Update azure db server tests

* Fixup merge

* Update comments

* Update more comments and remove junk code

* Move all azure api into lib/cloud/azure

* Update state and version checks

* Convert Azure DB Server into database

* Add mutex to subscription client for caching, just in case

* Test database conversion from azure db server

* Refactor common code

* Add azure matchers to watch config

* Remove unused imports

* Use common max pages in memorydb users

* Add azure clients to cloud clients

* Add azure fetchers to watcher

* Skip fetcher NotFound errors

* Add azure watcher tests

* Fix test comment

* Add wildcard region matching

* Remove redundant import

* Update lib/srv/db/cloud/watchers/azure.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Move db server listing logic into separate func

* Refactor some db conversion code

* Use local var to cache sub IDs

* Rename azure subscription client

* Rename azure subscription client and remove sub ID caching

* Move azure cloud clients into separate embedded interface

* Update watcher test for 'NotFound' handling

* Embed azureClients struct

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/subscriptions_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/cloud/azure/db_server_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Rename azure subscription client and remove sub ID caching

* Add reference links for azure db ports

* Move indirect dep into group

* Wrap all converted azure response errors

* Remove unreachable panic

* Godoc DBServer

* Remove maxPages arg to azure client funcs

* Gofmt

* Spacing between copyright and package

* import order

* Update lib/srv/db/cloud/watchers/azure.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Fix import order

* Refactor region matching

* Fix usage of azure clients to remove max pages arg

* Query azure subscriptions in fetcher.Get if matching wildcard subscription

* Fix azure matcher construction

* Test azure fetcher discovers new subscriptions

* Remove unused test helper func

* Set azure database resource id metadata

* Log errors when fetching from azure subscription fails

* Use more readable protocol in azure db description

* Get azure mysql engine version from labels

* Update lib/srv/db/cloud/watchers/watcher_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Update lib/srv/db/cloud/watchers/watcher_test.go

Co-authored-by: Marek Smoliński <marek@goteleport.com>

Co-authored-by: Marek Smoliński <marek@goteleport.com>

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
Co-authored-by: Marek Smoliński <marek@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure database-access Database access related issues and PRs db/mysql MySQL related database access issues db/postgres PostgreSQL related database access issues feature-request Used for new features in Teleport, improvements to current should be #enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants